package com.sinothk.hussars.controller;


import com.sinothk.hussars.base.BaseController;
import com.sinothk.hussars.entity.FileEntity;
import com.sinothk.hussars.service.FileService;
import com.sinothk.server.support.annotation.callback.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 文件表 前端控制器
 * </p>
 *
 * @author liangyt
 * @since 2021-01-02
 */
@Api(tags = "文件相关功能")
@RestController
@RequestMapping("/file")
@ResponseResult()
public class FileController extends BaseController {

    private final FileService fileService;

    public FileController(FileService fileService) {
        this.fileService = fileService;
    }

    @ApiOperation(value = "新增机构")
    @PostMapping("/save")
    public FileEntity save(@RequestBody FileEntity fileEntity) {
        try {
            fileService.save(fileEntity);
            return fileEntity;
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    }

}

